package game;

import java.awt.Graphics2D;
import java.awt.Point;

public class ClientStatus extends Button
{
	private static final long serialVersionUID = 1L;
	private float Contador;
	static int timeClient;
	public boolean OverClient;
	private int SecondImage, ThirdImage;
	private int ID;
	private float numberofdivision = 1;
	public int idSecond;
	public boolean activated;
	public enum StateClient
	{
		Green,
		Yellow,
		Red
	}
	
	StateClient status;
	
	public ClientStatus(Point position, Point size,
			int imgSelected, GameObject message,int idObject) {
		super(position, size, 21, imgSelected, message);
		// TODO Auto-generated constructor stub
		this.Contador = 0;
		timeClient = 30;
		this.status = StateClient.Green;
		this.SecondImage = 22;
		this.ThirdImage = 23;
		this.idSecond = idObject;
	}

	@Override
	public void Update() 
	{
		if(activated)
		{
			Contador += Time.getInstance().loopTime;
			if(this.Contador > this.timeClient / 3)
			{
				this.Contador = 0;
				
				switch(status)
				{
					case Green: this.firstImage = SecondImage; numberofdivision = 1;
						this.status = StateClient.Yellow;
					break;
					case Yellow: this.firstImage = ThirdImage; numberofdivision = 1.75f;
						this.status = StateClient.Red;
					break;
					case Red: numberofdivision = 2.5f;
				}		
		}
			if(this.status == StateClient.Red && this.Contador > this.timeClient / 3)
			{
				this.OverClient = true;
				activated = false;
				Contador = 0;
				//dar game over aqui
			}
			
			super.Update();
		}
	}

	public void GetID(int ID)
	{
		this.ID = ID;
	}
	
	public int GetMoney()
	{
		int Money = 0;
		switch(ID)
		{
			case 1: Money = (int) (100 / this.numberofdivision);break;
			case 2: Money = (int) (140 / this.numberofdivision);break;
			default: Money = (int) (180 / this.numberofdivision);break;
		}
		return Money;
	}
	@Override
	public void draw(Graphics2D g2d, Camera camera) {
		// TODO Auto-generated method stub
		if(activated)
			super.draw(g2d, camera);
	}
}
